package com.lzh.chatnote.chat.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 幂等类型
 */
@AllArgsConstructor
@Getter
public enum RoomStatusEnum {
    //0正常 1禁用
    NORMAL(0, "正常"),
    DISABLED(1, "禁用");

    private final Integer type;
    private final String desc;

    private static Map<Integer, RoomStatusEnum> cache;

    static {
        cache = Arrays.stream(RoomStatusEnum.values()).collect(Collectors.toMap(RoomStatusEnum::getType, Function.identity()));
    }

    public static RoomStatusEnum of(Integer type) {
        return cache.get(type);
    }
}
